package collection;

import java.util.ArrayList;
import java.util.Collection;
/** 集合中保存的是元素的地址 */
public class CollectionDemo3 {
    public static void main(String[] args) {
        Collection c = new ArrayList<>();
        Point p = new Point(1,2);
        c.add(p);//将P添加到集合c中----引用(地址)撞到了c中
        System.out.println(p);//(1,2)
        System.out.println(c);//[(1,2)]

        p.setX(100);
        System.out.println(c);//[(100,2)]
        System.out.println(p);//(100,2)
    }
}
